package com.diaohw.platform.framework.web;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "Content Type")
public enum ContentType {
    FORM_URLENCODED("application/x-www-form-urlencoded"),
    MULTIPART("multipart/form-data"),
    JSON("application/json"),
    PDF("application/pdf"),
    XML("application/xml"),
    TEXT("text/plain"),
    STREAM("application/octet-stream"),

    OFFICE_DOC("application/msword"),
    OFFICE_DOCX("application/vnd.openxmlformats-officedocument.wordprocessingml.document"),
    OFFICE_XLS("application/vnd.ms-excel"),
    OFFICE_XLSX("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),
    OFFICE_PPT("application/vnd.ms-powerpoint"),
    OFFICE_PPTX("application/vnd.openxmlformats-officedocument.presentationml.presentation"),

    IMAGE_PNG("image/png"),
    IMAGE_JPEG("image/jpeg"),
    IMAGE_GIF("image/gif"),
    IMAGE_TIFF("image/tiff"),
    IMAGE_SVG("image/svg+xml"),
    OTHER("other");

    public final String value;

    ContentType(String value) {
        this.value = value;
    }

    public static ContentType fromString(String value) {
        for (ContentType type : ContentType.values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return OTHER;
    }
}
